// Copyright (c) 2006 Zorm
// Released under the MIT License

#include "PCH.h"
#include "Common.h"

void Log::LogEvent(int logLevel, TCHAR *format, ...) {

	TCHAR formattedText[4096] = TEXT("");
	va_list vaArg;
	va_start(vaArg, format);
	_vsntprintf_s(formattedText, 4096, _TRUNCATE, format, vaArg);
	va_end(vaArg);
	ATH::Instance()->GetMainWindow()->TimeStamp();
	switch (logLevel) {
		case Log::LOG_ERROR: {
			ATH::Instance()->GetMainWindow()->SetColor(MainWindow::CRED);
			break;
		}
		case Log::LOG_WARNING: {
			ATH::Instance()->GetMainWindow()->SetColor(MainWindow::CYELLOW);
			break;
		}
		case Log::LOG_INFO: {
			ATH::Instance()->GetMainWindow()->SetColor(MainWindow::CGREY);
			break;
		}
		default: {
			__assume(0);
		}
	}
	ATH::Instance()->GetMainWindow()->AddText(TEXT("%s"), formattedText);

}